/**
 * @description 主题配置
 */
import { defineStore } from 'pinia'
import { ref } from 'vue'
//  引入主题
import { light, dark } from '@/config/theme/index'

export const useThemeStore = defineStore('theme', {
  // 状态
  state() {
    return {
      currentTheme: <'light' | 'dark'>'light'
    }
  },
  // 计算
  getters: {},
  // 动作
  actions: {
    toggleTheme(currentTheme: 'light' | 'dark') {
      const root = document.documentElement
      let Theme = null
      if (currentTheme == 'light') {
        Theme = light
      } else {
        Theme = dark
      }
      for (const key in Theme.global) {
        root.style.setProperty(`--${key}`, Theme.global[key])
      }
    }
  }
})
